/**
 * @param {number} x
 * @return {boolean}
 */
 var isPalindrome = function(x) {
  if (x < 0 || (x % 10 === 0 && x !== 0)) {
          return false;
      }
  
      let reversedNumber = 0;
      while (x > reversedNumber) {
          reversedNumber = reversedNumber * 10 + (x % 10);
          x = Math.floor(x / 10);
      }
      
      return x === revertedNumber || x === Math.floor(revertedNumber / 10);
  };